import 'package:flutter/material.dart';
import 'HomePage.dart';
import 'MinePage.dart';

class TabPage extends StatefulWidget {
  const TabPage({Key? key}) : super(key: key);

  @override
  State<TabPage> createState() => _TabPageState();
}

class _TabPageState extends State<TabPage> {
  int _currentIndex = 0;
  final List<String> _icons = ["tab_home", "tab_mine"];

  final PageController _controller = PageController(
    initialPage: 0,
  );

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PageView(
        physics: const NeverScrollableScrollPhysics(),
        controller: _controller,
        children: const [HomePage(), MinePage()],
      ),
      bottomNavigationBar: BottomNavigationBar(
        backgroundColor: Colors.white,
        selectedItemColor: const Color(0xFFFF8343),
        onTap: (index) {
          _controller.jumpToPage(index);
          setState(() {
            _currentIndex = index;
          });
        },
        currentIndex: _currentIndex,
        items: _icons
            .map((e) => BottomNavigationBarItem(
            icon: Image.asset(
              "images/$e.png",
              width: 30,
              color: _icons.indexOf(e) == _currentIndex
                  ? const Color(0xFFFF8343)
                  : Colors.grey,
            ),
            label: ""))
            .toList(),
      ),
    );
  }
}
